<?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class User extends Manage_Controller
{
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * 用户中心首页
	 */
	public function index()
	{
		$this->load->model('user_log_login_model', 'loginlog');
		$this->data['userlog'] = $this->loginlog->get_limit($this->uid, 2);

		//var_dump($this->user);exit;

		$this->load->library('postright');
		$this->data['postright'] = $this->postright->get_right($this->broker, $this->user);
		$this->load->view('manage/user_index', $this->data);
	}

	/**
	 * 用户基本资料
	 */
	public function profile()
	{
		if ($_POST)
		{

		}
		else
		{
			$this->load->helper('form');
			$this->load->view('manage/user_profile', $this->data);
		}
	}

	/**
	 * 修改用户头像
	 */
	public function avatar()
	{
		if ($_POST)
		{

		}
		else
		{
			$this->load->view('manage/user_avatar', $this->data);
		}
	}

	/**
	 * 修改用户密码
	 */
	public function password()
	{
		if ($_POST)
		{

		}
		else
		{
			$this->load->view('manage/user_password', $this->data);
		}
	}

	/**
	 * 修改用户认证
	 */
	public function auth()
	{
		if ($_POST)
		{

		}
		else
		{
			$this->load->view('manage/user_auth', $this->data);
		}
	}


	/**
	 * 修改用户资料
	 */
	public function edit($action)
	{
		//基本资料
		if ($action == 'profile')
		{
			if ($_POST)
			{

			}
			else
			{
				$this->load->view('manage/user_profile', $this->data);
			}
		}
		//修改头像
		elseif ($action == 'avatar')
		{

		}
		//密码安全
		elseif ($action == 'password')
		{

		}
	}

	/**
	 * 登录日志
	 */
	public function loginlog()
	{
		$this->load->model('user_log_login_model', 'loginlog');

		//get获取查询参数
		$page = intval($this->input->get('page', true)); //页数

		//分页
		$count = $this->loginlog->count_by('uid', $this->uid); //查询总数
		$config['base_url'] = site_url('manage/user/loginlog?'); //基本url
		$config['total_rows'] = $count; //总数据条数
		$config['per_page'] = 10; //每页显示多少条数据
		$this->load->library('pagination', $config);

		//根据条件查询需要显示的数据
        $loginlogs = array();
		if ($count)
		{
			$limit = $config['per_page']; //$this->pagination->per_page;
			$offset = $this->pagination->get_offset($page);
			$loginlogs = $this->loginlog->get_all($limit, $offset);
		}

		$this->data['page'] = $page;
        $this->data['loginlogs'] = $loginlogs;
		$this->load->view('manage/user_loginlog', $this->data);
	}
}

/* End of file user.php */
/* Location: ./application/controllers/manage/user.php */
